package cn.sitedev.simplefactory.courseclz;

import cn.sitedev.simplefactory.ICourse;

/**
 * @author qchen
 * @description
 * @date 2020/9/16 19:07
 */
public class CourseFactory {
    public ICourse create(Class<? extends ICourse> courseCls) {
        if (courseCls != null) {
            try {
                return courseCls.newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        throw new RuntimeException("该课程不存在");
    }
}
